//package com.clarice.homechef.controllers;
//
//import com.clarice.homechef.domain.User;
//import java.sql.Connection;
//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//import java.util.LinkedList;
//import java.util.List;
//import javax.sql.DataSource;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.bind.annotation.RequestMapping;
//
//@RestController
//@RequestMapping("/api")
//public class TestController {
//
//    @Autowired
//    DataSource dataSource;
//    private static String getUsers = "Select username, firstname, lastname, useremail From users";
//
//    @RequestMapping("/test")
//    public List<User> index() throws Exception {
//        List<User> users = new LinkedList<>();
//        try (Connection conn = dataSource.getConnection();
//                PreparedStatement ps = conn.prepareStatement(getUsers);) {
//            ResultSet rs = ps.executeQuery();
//            while (rs.next()) {
//                User user = new User();
//                user.setUsername(rs.getString("username"));
//                user.setName(rs.getString("firstname"));
//                user.setLastname(rs.getString("lastname"));
//                user.setUseremail(rs.getString("useremail"));
//                users.add(user);
//            }
//        } catch (Exception ex) {
//            System.out.println("Exception: " + ex.getMessage());
//            ex.printStackTrace();
//            throw ex;
//        }
//        return users;
//    }
//}
